﻿<%@ Page Title="" ValidateRequest="false" Language="C#" MasterPageFile="~/My/My.master" AutoEventWireup="true" CodeBehind="Photo.aspx.cs" Inherits="OpenPhotoAlbum.My.Photo" %>
<%@ Register Assembly="OpenPhotoAlbum" Namespace="OpenPhotoAlbum.Controls" TagPrefix="cc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ph1" runat="server">
	<asp:ScriptManagerProxy ID="scriptManagerProxy" runat="server">
		<Scripts>
			<asp:ScriptReference Path="~/My/VE.js" />
			<asp:ScriptReference Path="~/Controls/CommonScripts.js" />
		</Scripts>
	</asp:ScriptManagerProxy>
	<script language="javascript" type="text/javascript">
		function textChanged(sender, e) {
			var photoId = e.contextData1;
			var text = e.newText;
			var context = new Array(photoId, sender._labelElement.id, text);
			OpenPhotoAlbum.My.Photos.UpdatePhotoTitle(photoId, text, onSuccess, onFail, context);
			sender._labelElement.innerHTML = "<%= Resources.Strings.Saving %>";
		}
		function textChanged2(sender, e) {
			var photoId = e.contextData1;
			var text = e.newText;
			var context = new Array(photoId, sender._labelElement.id, text);
			OpenPhotoAlbum.My.Photos.UpdatePhotoDescription(photoId, text, onSuccess, onFail, context);
			sender._labelElement.innerHTML = "<%= Resources.Strings.Saving %>";
		}
		function onSuccess(result, context) {
			var photoId = context[0];
			var id = context[1];
			var text = context[2];
			setText($get(id), text);
		}
		function onFail(param) {
			debugger;
		}
		function onReset() {
			restoreLastSelectedVeItem();
			$get($imgId).src = $originalUrl;
			hideProgressPlaceHolder();
			$isProcessing = false;
			$get('btnVeSave').disabled = true;
			$get('btnVeSaveAs').disabled = true;
		}
		function onSave() {
			if (!$lastSelectedVeName) { return; }

			$get('veMain').style.display = 'none';
			$get('veWait').style.display = '';
			$get('veWait').innerHTML = '<%= Resources.Strings.VE_Saving %>';
			OpenPhotoAlbum.My.Photos.SaveVisualEffect('<%= OpenPhotoAlbum.UrlContext.PhotoId %>', $lastSelectedVeName, onSaveSuccess, onFail, true);
		}
		function onSaveAs() {
			if (!$lastSelectedVeName) { return; }

			$get('veMain').style.display = 'none';
			$get('veWait').style.display = '';
			$get('veWait').innerHTML = '<%= Resources.Strings.VE_SavingAsNewPhoto %>';
			OpenPhotoAlbum.My.Photos.SaveVisualEffectAs('<%= OpenPhotoAlbum.UrlContext.PhotoId %>', $lastSelectedVeName, onSaveSuccess, onFail, false);
		}
		function onSaveSuccess(result, context) {
			var needRefresh = context;
			if (needRefresh) {
				alert('<%= Resources.Strings.VE_Saved %>');
				location.reload(true);
			}
			else {
				alert('<%= Resources.Strings.VE_SavedAsNewPhoto %>');
				//$get('veMain').style.display = '';
				//$get('veWait').style.display = 'none';
				document.location.href = '<%= this.AlbumUrl.Replace("'", "\\'") %>';
			}
		}
		function copy() {
			var addr = getText($get('address'));
			copyToClipboard(addr);
		}
	</script>
	<div id="divPhoto" class="photo">
		<cc:TabPanels ID="tabPanels" runat="server" />
		<span class="title"><cc:InplaceEditLabel ID="lblTitle" runat="server" OnClientTextChanged="textChanged" /></span>
		<span class="img"><asp:Image ID="imgPhoto" runat="server" /></span>
		<span class="description"><cc:InplaceEditLabel ID="lblDescription" runat="server" OnClientTextChanged="textChanged2" IsMultiLine="true" /></span>
		<span class="creationDate"><asp:Label ID="lblCreationDate" runat="server" /></span>
		<span class="commands"><cc:AlbumCommandLinkButton ID="linkBtnDelete" runat="server" /></span>
		<div>&nbsp;</div>
	</div>
	
	<cc:TooltipExtender ID="ttTitle" runat="server" TargetControlID="lblTitle" ParentElementId="divPhoto" Position="Right" />
	<cc:TooltipExtender ID="ttDescription" runat="server" TargetControlID="lblDescription" ParentElementId="divPhoto" Position="Right" />
	
	<cc:TabPanel ID="pnlSharingAddress" runat="server" CssClass="sharingAddress">
		<div class="explanation"><%= Resources.Strings.SharingAddress_Explanation %></div>
		<div id="address" class="address"><asp:Literal ID="ltrSharingAddress" runat="server" /></div>
		<div class="btn">
			[<asp:HyperLink ID="hlVisit" runat="server" Target="_blank" />]
			[<a href="javascript:copy();"><%= Resources.Strings.CopyToClipboard %></a>]
		</div>
	</cc:TabPanel>
	
	<cc:TabPanel ID="pnlVisualEffects" runat="server" CssClass="veItems">
		<div id="veMain">
			<span class="veItemNegativeImage" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.NegativeImage %>"><%= Resources.Strings.VE_NegativeImage %></span>
			<span class="veItemConvax" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Convax %>"><%= Resources.Strings.VE_Convax %></span>
			<span class="veItemEdgeDetection" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.EdgeDetection %>"><%= Resources.Strings.VE_EdgeDetection %></span>
			<span class="veItemEmboss" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Emboss %>"><%= Resources.Strings.VE_Emboss %></span>
			<span class="veItemGlass" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Glass %>"><%= Resources.Strings.VE_Glass %></span>
			<span class="veItemMosaic" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Mosaic %>"><%= Resources.Strings.VE_Mosaic %></span>
			<span class="veItemSketch" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Sketch %>"><%= Resources.Strings.VE_Sketch %></span>
			<span class="veItemSketchHeavy" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.SketchHeavy %>"><%= Resources.Strings.VE_SketchHeavy %></span>
			<span class="veItemOldPhoto" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.OldPhoto %>"><%= Resources.Strings.VE_OldPhoto %></span>
			<span class="veItemRoundedCorners" id="<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.RoundedCorners  %>"><%= Resources.Strings.VE_RoundedCorners %></span>
			<div class="buttons">
				<input id="btnVeSave" type="button" value="<%= Resources.Strings.Save %>" disabled="true" onclick="onSave()" />
				<input id="btnVeSaveAs" type="button" value="<%= Resources.Strings.VE_SaveAsNewPhoto %>" disabled="true" onclick="onSaveAs()" />
				<input id="btnVeReset" type="button" value="<%= Resources.Strings.Reset %>" onclick="onReset()" />
			</div>
		</div>
		<div id="veWait" style="display:none; line-height:300%; font-weight:bold; font-size:1.3em;"></div>
	</cc:TabPanel>
	
	<script type="text/javascript">
		var $imgId = '<%= imgPhoto.ClientID %>';
		var $urlFormat = '<%= this.UrlFormat %>';
		var $buttons = new Array();
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.NegativeImage %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Convax %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.EdgeDetection %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Emboss  %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Glass %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Mosaic %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.Sketch %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.SketchHeavy %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.OldPhoto %>');
		$buttons.push('<%= OpenPhotoAlbum.Controls.PhotoProcessors.VisualEffects.RoundedCorners %>');
	</script>
</asp:Content>
